package com.wq.controller;

import com.wq.BusinessException;
import com.wq.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(BusinessException.class)
    public Result<String> handleBusinessException(BusinessException e) {
        String s = String.valueOf(e.getResp().getCode());
        return Result.error(e.getResp().getMessage());
    }
    
    // 处理其他未预期的异常
    @ExceptionHandler(Exception.class)
    public Result<String> handleException(Exception e) {
        return Result.error( "系统繁忙，请稍后再试");
    }
}
